package com.hmeter.hadoop.hdfs;

import java.beans.PropertyDescriptor;

import org.apache.jmeter.testbeans.BeanInfoSupport;
import org.apache.jmeter.testbeans.gui.GenericTestBeanCustomizer;
import org.apache.jmeter.testbeans.gui.TypeEditor;

import com.hmeter.util.BooleanPropertyEditor;

/**
 * UI descriptor for {@link HDFSSampler}
 * 
 * @author dino.keco
 * @version 1.0
 * @since 1.0
 * 
 */
public class HDFSSamplerBeanInfo extends BeanInfoSupport {

	public HDFSSamplerBeanInfo() {
		super(HDFSSampler.class);

		createPropertyGroup("config", new String[] { "nameNode" });
		PropertyDescriptor p = property("nameNode");
		p.setValue(DEFAULT, "");
		p.setValue(NOT_UNDEFINED, Boolean.TRUE);

		createPropertyGroup("file", new String[] { "path" });
		p = property("path");
		p.setValue(DEFAULT, "");
		p.setValue(NOT_UNDEFINED, Boolean.TRUE);

		createPropertyGroup("create", new String[] { "createActive", "content", "upload", "overwrite", "createCodec" });
		p = property("createActive");
		p.setPropertyEditorClass(BooleanPropertyEditor.class);

		p = property("content");
		p.setValue(DEFAULT, "");
		p.setValue(NOT_UNDEFINED, Boolean.TRUE);
		p.setValue(GenericTestBeanCustomizer.GUITYPE, TypeEditor.TextAreaEditor);

		p = property("upload");
		p.setValue(DEFAULT, "");
		p.setValue(NOT_UNDEFINED, Boolean.TRUE);
		p.setValue(GenericTestBeanCustomizer.GUITYPE, TypeEditor.FileEditor);

		p = property("overwrite");
		p.setPropertyEditorClass(BooleanPropertyEditor.class);

		p = property("createCodec");
		p.setValue(DEFAULT, "");
		p.setValue(NOT_UNDEFINED, Boolean.TRUE);
		p.setValue(TAGS, HDFSUtil.COODECS);

		createPropertyGroup("delete", new String[] { "deleteActive", "recursive" });
		p = property("deleteActive");
		p.setPropertyEditorClass(BooleanPropertyEditor.class);

		p = property("recursive");
		p.setPropertyEditorClass(BooleanPropertyEditor.class);

		createPropertyGroup("rename", new String[] { "renameActive", "newName" });
		p = property("renameActive");
		p.setPropertyEditorClass(BooleanPropertyEditor.class);

		p = property("newName");
		p.setValue(DEFAULT, "");
		p.setValue(NOT_UNDEFINED, Boolean.TRUE);

		createPropertyGroup("tail", new String[] { "tailActive", "offset", "size", "info", "tailCodec" });

		p = property("tailActive");
		p.setPropertyEditorClass(BooleanPropertyEditor.class);

		p = property("offset");
		p.setValue(DEFAULT, 0);
		p.setValue(NOT_UNDEFINED, Boolean.TRUE);

		p = property("size");
		p.setValue(DEFAULT, 100);
		p.setValue(NOT_UNDEFINED, Boolean.TRUE);

		p = property("info");
		p.setPropertyEditorClass(BooleanPropertyEditor.class);

		p = property("tailCodec");
		p.setValue(DEFAULT, "");
		p.setValue(NOT_UNDEFINED, Boolean.TRUE);
		p.setValue(TAGS, HDFSUtil.COODECS);
	}

}
